#include "ys_bzgl_3103.h"
#include "ui_ys_bzgl_3103.h"

#include "pub_var.h"
#include <QSettings>
#include <QMessageBox>
#include <QJsonDocument>
#include <QNetworkReply>
#include <QSqlError>
#include <QTimer>

Ys_bzgl_3103::Ys_bzgl_3103(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Ys_bzgl_3103)
{
    ui->setupUi(this);

    ui->pushButton_2->setVisible(false);//接收默认回车信号

    //恢复当前窗口位置
    QSettings setIni("clin.ini", QSettings::IniFormat);
    QRect rct = setIni.value("windowState/form_bzgl_3103").toRect();
    this->setGeometry(rct);

}

Ys_bzgl_3103::~Ys_bzgl_3103()
{
    delete ui;
}


void Ys_bzgl_3103::closeEvent(QCloseEvent *event)
{
    Q_UNUSED(event);
    QSettings setIni("clin.ini", QSettings::IniFormat);
    setIni.setValue("windowState/form_bzgl_3103", QVariant(this->geometry()));
    //destroyW("bzgl_");

}

void Ys_bzgl_3103::on_pb_ok_clicked()
{

    if(ui->rb_continue->isChecked())
    {
        if(ui->pt_reason->toPlainText().trimmed().isEmpty())
        {

            QMessageBox::warning(this, "注意", "选择继续保存，必须输入原因！");
            return;
        }

    }

    this->close();
}

void Ys_bzgl_3103::prepare_display(QStringList para)
{

    if(para.size() < 2)
    {
        QMessageBox::warning(this, "Note", "Ys_bzgl_3103::prepare_display 参数错误！");
        return;
    }

    //QString jr_id = para[0];
    QString rule_name = para[0];
    QString vola_cont = para[1];

    ui->le_err_msg->setText(rule_name + " : " + vola_cont);

}


QList<QMap<QString, QString>> Ys_bzgl_3103::return_values()
{
    QList<QMap<QString, QString>> ret_values;
    QMap<QString, QString> mp;

    mp["reason"] = ui->pt_reason->toPlainText().trimmed();

    if(ui->rb_ret->isChecked())
    {
        mp["mode"] = "2";//"return";
    }
    else
    {
        mp["mode"] = "1";//"continue";
    }

    ret_values << mp;

    return ret_values;

}


